Skip to content

Conversation

Lung-Alexandra
Copy link
Contributor

This PR fixes #18081.

This pull request addresses several memory leak issues detected by cppchecker in the following files:

  • fuzzer-json.c (line 39):
    Added a free(data) call to release the allocated memory before returning.

  • fuzzer-mbregex.c (line 39):
    Implemented a similar fix by freeing the allocated memory for data when fuzzer_request_startup() fails.

  • fuzzer-unserialize.c (line 38):
    Now frees orig_data before returning when an error is detected.

  • fuzzer-unserializehash.c (line 43):
    Modified the error path to call free(orig_data) if fuzzer_request_startup() fails.

These changes ensure that memory allocated is properly released if fuzzer_request_startup() fails, preventing memory leaks.

@nielsdos
Copy link
Member

This affects lower branches too, please target the lowest supported bugfix branch, i.e. PHP-8.3.

@nielsdos
Copy link
Member

It's probably also better to just move the allocation under the request initialization, then you don't even need the call to free.

@Lung-Alexandra Lung-Alexandra changed the base branch from master to PHP-8.3 March 16, 2025 07:12
@TimWolla
Copy link
Member

This needs to be properly rebased when changing the target branch.

@Lung-Alexandra
Copy link
Contributor Author

@TimWolla squashed and rebased over PHP-8.3

Copy link
Contributor

@staabm staabm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabs vs spaces mixed up in all files

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix indentation to use tabs

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

nielsdos added a commit that referenced this pull request Mar 16, 2025
* PHP-8.3:
  Fix GH-18082: Memory leaks in fuzzer SAPI error paths
@nielsdos nielsdos closed this in 38e553e Mar 16, 2025
nielsdos added a commit that referenced this pull request Mar 16, 2025
* PHP-8.4:
  Fix GH-18082: Memory leaks in fuzzer SAPI error paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants